/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Random;

/**
 * <p>Project: jse2302 - Ex7
 * <p>Powered by webrx On 2023-06-20 10:10:38
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex7 {
    public static void main(String[] args) {
        //随机密码8位
        String lettera = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_-+{}|\\\"'][=-,.<>?`";
        StringBuilder sbu = new StringBuilder();
        Random rand = new Random();
        for (int i = 0; i < 8; i++) {
            sbu.append(lettera.charAt(rand.nextInt(lettera.length())));
        }
        String pwd = sbu.toString();
        System.out.println(pwd.length());
        System.out.println(pwd);


        //随机验证码
        String cs = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        sbu.delete(0,sbu.length());
        for (int i = 0; i < 4; i++) {
            sbu.append(cs.charAt(rand.nextInt(cs.length())));
        }
        System.out.println(sbu);
    }
}
